package com.xzavier.yunlian_interview.controller;

import com.xzavier.yunlian_interview.entity.User;
import com.xzavier.yunlian_interview.service.UserService;
import com.xzavier.yunlian_interview.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("interview/User")
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("reg")
    public JsonResult<Integer> register(String username, String password) {

        Integer register = userService.register(username, password);
        return new JsonResult<Integer>(200, register);

    }

    @PostMapping("login")
    public JsonResult<User> Login(String username, String password) {
        User user = userService.login(username, password);
        return new JsonResult<User>(200, user);

    }

}
